<table class="gh-list gh-history-table">
    <thead>
        <tr>
            <th>&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        {{#each @events as |event|}}
        {{#let (parse-history-event event) as |ev|}}
        <tr>
            <div class="gh-list-data">
                <div class="gh-history-object flex items-center ma3">
                    <span class="user-list-item-figure" style={{background-image-style ev.actorIcon}}>
                        {{#if ev.actor.name}}
                            <span class="hidden">Photo of {{ev.actor.name}}</span>
                        {{/if}}
                        <div class="gh-history-icon">{{svg-jar ev.actionIcon}}</div>
                    </span>
                    {{!--  --}}
                    <div>
                        <div class="gh-history-description">
                            <span>
                                {{capitalize-first-letter ev.action}}:
                            </span>
                            {{#if ev.contextResource}}
                                <span>
                                    <span>{{capitalize-first-letter ev.contextResource.first}}</span>
                                    {{#if (not (eq ev.contextResource.first ev.contextResource.second))}}
                                        <code>({{ev.contextResource.second}})</code>
                                    {{/if}}
                                </span>
                            {{else if (or ev.original.resource.title ev.original.resource.name ev.original.context.primary_name)}}
                                {{#if ev.linkTarget}}
                                    {{#if ev.linkTarget.models}}
                                        <LinkTo @route={{ev.linkTarget.route}} @models={{ev.linkTarget.models}} class="permalink fw6">
                                            {{or ev.original.resource.title ev.original.resource.name}}
                                        </LinkTo>
                                    {{else}}
                                        <LinkTo @route={{ev.linkTarget.route}} class="permalink fw6">
                                            {{or ev.original.resource.title ev.original.resource.name}}
                                        </LinkTo>
                                    {{/if}}
                                {{else}}
                                    <span>{{or ev.original.resource.title ev.original.resource.name ev.original.context.primary_name}}</span>
                                {{/if}}
                            {{else}}
                                <span class="midlightgrey">(unknown)</span>
                            {{/if}}

                            <span class="gh-history-name">
                                <span class="midgrey">&ndash; by </span>
                                {{#if ev.actorLinkTarget}}
                                    <LinkTo @route={{ev.actorLinkTarget.route}} @models={{ev.actorLinkTarget.models}}>
                                        {{ev.actor.name}}
                                    </LinkTo>
                                {{else}}
                                    (deleted user)
                                {{/if}}
                            </span>
                        </div>
                        <div class="gh-history-datetime">{{moment-format ev.original.created_at "DD MMM YYYY | HH:mm:ss"}}</div>
                    </div>
                </div>
            </div>
        </tr>
        {{/let}}
        {{/each}}
    </tbody>
</table>
